<?php

namespace App\Models;

use Illuminate\Database\Eloquent\SoftDeletes;

class Project extends Model
{
    use SoftDeletes;

    protected $dates = ['deleted_at'];

    protected $guarded = [];


    public function getPorjectList($params)
    {
        // 开启执行日志
        \DB::connection()->enableQueryLog();

        $pageSize = empty($params['page_size']) ? config('sdblog.pageSize') : $params['page_size'];
        $page = empty($params['page']) ? 1 : $params['page'];
        $query = $this->orderBy('created_at', "desc");
        !empty($params["project_type_id"]) && $query->where('project_type_id', $params["project_type_id"]);
        !empty($params["is_enable"]) && $query->where('is_enable', $params["is_enable"] ? self::TRUE_STATUS : self::FALSE_STATUS);
        return $query->paginate($pageSize, ["*"], 'page', $page);
    }
}
